package cn.dyw.cloudmusic.dao;

import cn.dyw.cloudmusic.entity.Ar;
import cn.dyw.cloudmusic.music.vo.Songs;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ArMapper {
    /**
     */
    @Delete({
        "delete from ar",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    /**
     */
    @Insert({
        "insert into ar (id, name, ",
        "music_id)",
        "values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
        "#{musicId,jdbcType=VARCHAR})"
    })
    int insert(Ar record);

    /**
     */
    @Insert({
            "insert ignore ar (id, name, ",
            "music_id)",
            "values (#{ar.id,jdbcType=VARCHAR}, #{ar.name,jdbcType=VARCHAR}, ",
            "#{songs.id,jdbcType=VARCHAR})"
    })
    int insertVo(@Param("ar") cn.dyw.cloudmusic.music.vo.Ar ar, @Param("songs") Songs songs);

    int insertList(@Param("ars") List<cn.dyw.cloudmusic.music.vo.Ar> ars, @Param("songs") Songs songs);

    /**
     */
    int insertSelective(Ar record);

    /**
     */
    @Select({
        "select",
        "id, name, music_id",
        "from ar",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @ResultMap("cn.dyw.cloudmusic.dao.ArMapper.BaseResultMap")
    Ar selectByPrimaryKey(String id);

    /**
     */
    int updateByPrimaryKeySelective(Ar record);

    /**
     */
    @Update({
        "update ar",
        "set name = #{name,jdbcType=VARCHAR},",
          "music_id = #{musicId,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Ar record);
}